package legumes.shared.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Id;

import com.googlecode.objectify.annotation.Serialized;

public class SellSession implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id private long creationDate;
	@Serialized private List<Order> orders;
	@Serialized private Stall stall;

	public SellSession() {
		setStall(new Stall());
		setOrders(new ArrayList<Order>());
		setCreationDate(new Date().getTime());
	}

	public Stall getStall() {
		return stall;
	}

	public void setStall(Stall stall_) {
		stall_.setSellSessionDate(getCreationDate());
		stall = stall_;
	}

	@Override
	public String toString() {
		return "[SellSession " + " creationDate=" + getCreationDate()
				+ "\n\torders" + getOrders() + "\n]";

	}

	public long getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(long creationDate) {
		this.creationDate = creationDate;
	}

	public List<Order> getOrders() {
		return orders;
	}

	public void setOrders(ArrayList<Order> orders) {
		this.orders = orders;
	}

	public void addOrder(Order o_) {
		getOrders().add(o_);
	}

	public void removeOrder(Order o_) {
		getOrders().remove(o_);
	}

}
